package cn.iocoder.yudao.module.trade.dal.mysql.giftcard;

import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.trade.dal.dataobject.giftcard.GiftCardDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.giftcard.GiftCardReceiveGiveDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper
public interface GiftCardReceiveGiveMapper extends BaseMapperX<GiftCardReceiveGiveDO> {

    default List<GiftCardReceiveGiveDO> queryGiftCardReceiveGiver(Long receiveMemberUserId) {
        return selectList(new LambdaQueryWrapperX<GiftCardReceiveGiveDO>()
                .eq(GiftCardReceiveGiveDO::getReceiveMemberUserId, receiveMemberUserId)
                .isNotNull(GiftCardReceiveGiveDO::getGiveTime)
                .orderByDesc(GiftCardReceiveGiveDO::getCreateTime));
    }

    default List<GiftCardReceiveGiveDO> queryGiftCardReceiveGiverTime(Long cardId) {
        return selectList(new LambdaQueryWrapperX<GiftCardReceiveGiveDO>()
                .eq(GiftCardReceiveGiveDO::getGiftCardId, cardId)
                .isNull(GiftCardReceiveGiveDO::getGiveTime)
                .orderByDesc(GiftCardReceiveGiveDO::getCreateTime));
    }

    default List<GiftCardReceiveGiveDO> queryByCardId(Long cardId) {
        return selectList(new LambdaQueryWrapperX<GiftCardReceiveGiveDO>()
                .eq(GiftCardReceiveGiveDO::getGiftCardId, cardId)
                .orderByDesc(GiftCardReceiveGiveDO::getCreateTime));
    }


}
